@editora/plugins 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CodePlugin.native-CmnEFfJi.mjs +646 -0
- package/dist/CodePlugin.native-Cqi46sxh.js +460 -0
- package/dist/code.cjs.js +1 -669
- package/dist/code.esm.js +2 -4560
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-Jf0RbSks.js → documentManager-3nPkITwx.js} +2 -2
- package/dist/{documentManager-CTqRftU8.mjs → documentManager-CRumGpCT.mjs} +3 -3
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +1 -1
- package/dist/{index-BFsKNTTj.mjs → index-CJ90EVWy.mjs} +3 -3
- package/dist/index-CxhJLMPS.js +221 -0
- package/dist/{index-tqLTHcO6.js → index-DTkvH8gX.js} +1 -1
- package/dist/{index-D3CycEFU.mjs → index-Di1ZqIDs.mjs} +6420 -6232
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-DQ78mYYo.mjs → index.es-B7pVaNEV.mjs} +1558 -1542
- package/dist/{index.es-CE_A4QSm.js → index.es-I9N4o4Iq.js} +5 -5
- package/dist/index.esm.js +2 -2
- package/dist/{jspdf.es.min-BoS80556.js → jspdf.es.min-B5Idu0Wl.js} +2 -2
- package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-BCzHIwvz.mjs} +3 -2
- package/dist/{purify.es-T2a3nLiC.js → purify.es-DWpzYfqy.js} +1 -1
- package/dist/{purify.es-DHhaBdbu.mjs → purify.es-Dewe88eZ.mjs} +2 -2
- package/package.json +3 -3
- package/dist/index-CvJk4DKa.js +0 -221
|
@@ -0,0 +1,646 @@
|
|
|
1
|
+
import { createEditor as Z, LineNumbersExtension as I, ThemeExtension as U, ReadOnlyExtension as P, BracketMatchingExtension as _, SearchExtension as $, CodeFoldingExtension as K, SyntaxHighlightingExtension as Y } from "@editora/light-code-editor";
|
|
2
|
+
const L = '[data-theme="dark"], .dark, .editora-theme-dark', G = `/* Source Editor Dialog Styles */
|
|
3
|
+
.rte-source-editor-overlay {
|
|
4
|
+
position: fixed !important;
|
|
5
|
+
top: 0 !important;
|
|
6
|
+
left: 0 !important;
|
|
7
|
+
right: 0 !important;
|
|
8
|
+
bottom: 0 !important;
|
|
9
|
+
width: 100vw !important;
|
|
10
|
+
height: 100vh !important;
|
|
11
|
+
background-color: rgba(0, 0, 0, 0.6) !important;
|
|
12
|
+
display: flex !important;
|
|
13
|
+
align-items: center !important;
|
|
14
|
+
justify-content: center !important;
|
|
15
|
+
z-index: 10000 !important;
|
|
16
|
+
padding: 20px !important;
|
|
17
|
+
box-sizing: border-box !important;
|
|
18
|
+
margin: 0 !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rte-source-editor-overlay.fullscreen {
|
|
22
|
+
padding: 0 !important;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.rte-source-editor-modal {
|
|
26
|
+
background: white;
|
|
27
|
+
border-radius: 8px;
|
|
28
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
29
|
+
width: 100%;
|
|
30
|
+
max-width: 1200px;
|
|
31
|
+
max-height: 90vh;
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
position: relative;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.rte-source-editor-overlay.fullscreen .rte-source-editor-modal {
|
|
39
|
+
border-radius: 0;
|
|
40
|
+
max-width: 100%;
|
|
41
|
+
max-height: 100vh;
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100vh;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.rte-source-editor-header {
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: space-between;
|
|
50
|
+
padding: 16px 20px;
|
|
51
|
+
border-bottom: 1px solid #e1e5e9;
|
|
52
|
+
background: #f8f9fa;
|
|
53
|
+
border-radius: 8px 8px 0 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.rte-source-editor-overlay.fullscreen .rte-source-editor-header {
|
|
57
|
+
border-radius: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.rte-source-editor-header h2 {
|
|
61
|
+
margin: 0;
|
|
62
|
+
font-size: 18px;
|
|
63
|
+
font-weight: 600;
|
|
64
|
+
color: #1a1a1a;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.rte-source-editor-header-toolbar {
|
|
68
|
+
display: flex;
|
|
69
|
+
gap: 8px;
|
|
70
|
+
margin-left: auto;
|
|
71
|
+
margin-right: 16px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.rte-source-editor-toolbar-btn {
|
|
75
|
+
background: none;
|
|
76
|
+
border: none;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
padding: 6px;
|
|
79
|
+
border-radius: 4px;
|
|
80
|
+
font-size: 16px;
|
|
81
|
+
line-height: 1;
|
|
82
|
+
transition: all 0.2s ease;
|
|
83
|
+
color: #666;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.rte-source-editor-toolbar-btn:hover:not(:disabled) {
|
|
87
|
+
background: #e1e5e9;
|
|
88
|
+
color: #1a1a1a;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.rte-source-editor-toolbar-btn:disabled {
|
|
92
|
+
opacity: 0.5;
|
|
93
|
+
cursor: not-allowed;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.rte-source-editor-toolbar-btn.active {
|
|
97
|
+
background: #007acc;
|
|
98
|
+
color: white;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.rte-source-editor-toolbar-btn.active:hover {
|
|
102
|
+
background: #0056b3;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.rte-source-editor-header-actions {
|
|
106
|
+
display: flex;
|
|
107
|
+
gap: 8px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.rte-source-editor-fullscreen-btn,
|
|
111
|
+
.rte-source-editor-close-btn {
|
|
112
|
+
background: none;
|
|
113
|
+
border: none;
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
padding: 4px;
|
|
116
|
+
border-radius: 4px;
|
|
117
|
+
color: #666;
|
|
118
|
+
font-size: 16px;
|
|
119
|
+
line-height: 1;
|
|
120
|
+
transition: all 0.2s ease;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.rte-source-editor-fullscreen-btn:hover,
|
|
124
|
+
.rte-source-editor-close-btn:hover {
|
|
125
|
+
background: #e1e5e9;
|
|
126
|
+
color: #1a1a1a;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.rte-source-editor-body {
|
|
130
|
+
flex: 1;
|
|
131
|
+
overflow: hidden;
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.rte-source-editor-loading {
|
|
137
|
+
display: flex;
|
|
138
|
+
flex-direction: column;
|
|
139
|
+
align-items: center;
|
|
140
|
+
justify-content: center;
|
|
141
|
+
padding: 40px;
|
|
142
|
+
color: #666;
|
|
143
|
+
position: absolute;
|
|
144
|
+
z-index: 9;
|
|
145
|
+
margin: 0 auto;
|
|
146
|
+
width: 100%;
|
|
147
|
+
top: 44%;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.rte-source-editor-spinner {
|
|
151
|
+
width: 32px;
|
|
152
|
+
height: 32px;
|
|
153
|
+
border: 3px solid #e1e5e9;
|
|
154
|
+
border-top: 3px solid #007acc;
|
|
155
|
+
border-radius: 50%;
|
|
156
|
+
animation: spin 1s linear infinite;
|
|
157
|
+
margin-bottom: 16px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@keyframes spin {
|
|
161
|
+
0% { transform: rotate(0deg); }
|
|
162
|
+
100% { transform: rotate(360deg); }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.rte-source-editor-error {
|
|
166
|
+
background: #fee;
|
|
167
|
+
color: #c53030;
|
|
168
|
+
padding: 12px 16px;
|
|
169
|
+
border-left: 4px solid #c53030;
|
|
170
|
+
margin: 16px;
|
|
171
|
+
border-radius: 4px;
|
|
172
|
+
font-size: 14px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.rte-source-editor-content {
|
|
176
|
+
flex: 1;
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
overflow: hidden;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.rte-source-editor-warning {
|
|
183
|
+
background: #fefcbf;
|
|
184
|
+
color: #744210;
|
|
185
|
+
padding: 8px 16px;
|
|
186
|
+
font-size: 12px;
|
|
187
|
+
font-weight: 500;
|
|
188
|
+
border-bottom: 1px solid #f6e05e;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.rte-source-editor-codemirror {
|
|
192
|
+
flex: 1;
|
|
193
|
+
overflow: auto;
|
|
194
|
+
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
195
|
+
font-size: 14px;
|
|
196
|
+
line-height: 1.5;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.rte-source-editor-codemirror .cm-editor {
|
|
200
|
+
height: 100%;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.rte-source-editor-codemirror .cm-focused {
|
|
204
|
+
outline: none;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.rte-source-editor-footer {
|
|
208
|
+
display: flex;
|
|
209
|
+
align-items: center;
|
|
210
|
+
justify-content: space-between;
|
|
211
|
+
padding: 16px 20px;
|
|
212
|
+
border-top: 1px solid #e1e5e9;
|
|
213
|
+
background: #f8f9fa;
|
|
214
|
+
border-radius: 0 0 8px 8px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.rte-source-editor-overlay.fullscreen .rte-source-editor-footer {
|
|
218
|
+
border-radius: 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.rte-source-editor-footer-info {
|
|
222
|
+
font-size: 12px;
|
|
223
|
+
color: #666;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.unsaved-changes {
|
|
227
|
+
color: #d69e2e;
|
|
228
|
+
font-weight: 500;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.rte-source-editor-footer-actions {
|
|
232
|
+
display: flex;
|
|
233
|
+
gap: 12px;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.rte-source-editor-btn {
|
|
237
|
+
padding: 8px 16px;
|
|
238
|
+
border-radius: 4px;
|
|
239
|
+
font-size: 14px;
|
|
240
|
+
font-weight: 500;
|
|
241
|
+
cursor: pointer;
|
|
242
|
+
border: 1px solid transparent;
|
|
243
|
+
transition: all 0.2s ease;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.rte-source-editor-btn:disabled {
|
|
247
|
+
opacity: 0.6;
|
|
248
|
+
cursor: not-allowed;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.rte-source-editor-btn-cancel {
|
|
252
|
+
background: white;
|
|
253
|
+
border-color: #d1d5db;
|
|
254
|
+
color: #374151;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.rte-source-editor-btn-cancel:hover:not(:disabled) {
|
|
258
|
+
background: #f9fafb;
|
|
259
|
+
border-color: #9ca3af;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.rte-source-editor-btn-save {
|
|
263
|
+
background: #007acc;
|
|
264
|
+
color: white;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.rte-source-editor-btn-save:hover:not(:disabled) {
|
|
268
|
+
background: #0056b3;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-modal {
|
|
272
|
+
background: #1e1e1e;
|
|
273
|
+
color: #f8f9fa;
|
|
274
|
+
border: 1px solid #434d5f;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-header,
|
|
278
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-footer {
|
|
279
|
+
background: #2a3442;
|
|
280
|
+
border-color: #434d5f;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-header h2 {
|
|
284
|
+
color: #f8f9fa;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn,
|
|
288
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-fullscreen-btn,
|
|
289
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-close-btn {
|
|
290
|
+
color: #c1cede;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn:hover:not(:disabled),
|
|
294
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-fullscreen-btn:hover,
|
|
295
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-close-btn:hover {
|
|
296
|
+
background: #404a5a;
|
|
297
|
+
color: #f8fafc;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn.active {
|
|
301
|
+
background: #3b82f6;
|
|
302
|
+
color: #ffffff;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn.active:hover {
|
|
306
|
+
background: #2563eb;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-loading,
|
|
310
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-footer-info {
|
|
311
|
+
color: #cbd5e1;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-spinner {
|
|
315
|
+
border-color: #3f4b60;
|
|
316
|
+
border-top-color: #58a6ff;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-error {
|
|
320
|
+
background: #3f2124;
|
|
321
|
+
color: #fecaca;
|
|
322
|
+
border-color: #ef4444;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-warning {
|
|
326
|
+
background: #3b3220;
|
|
327
|
+
color: #fde68a;
|
|
328
|
+
border-color: #f59e0b;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-cancel {
|
|
332
|
+
background: #334155;
|
|
333
|
+
border-color: #475569;
|
|
334
|
+
color: #f1f5f9;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-cancel:hover:not(:disabled) {
|
|
338
|
+
background: #475569;
|
|
339
|
+
border-color: #64748b;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-save {
|
|
343
|
+
background: #3b82f6;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-save:hover:not(:disabled) {
|
|
347
|
+
background: #2563eb;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/* Responsive design */
|
|
351
|
+
@media (max-width: 768px) {
|
|
352
|
+
.rte-source-editor-overlay {
|
|
353
|
+
padding: 10px;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.rte-source-editor-modal {
|
|
357
|
+
max-height: 95vh;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.rte-source-editor-header {
|
|
361
|
+
padding: 12px 16px;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.rte-source-editor-footer {
|
|
365
|
+
padding: 12px 16px;
|
|
366
|
+
flex-direction: column;
|
|
367
|
+
gap: 12px;
|
|
368
|
+
align-items: stretch;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.rte-source-editor-footer-actions {
|
|
372
|
+
justify-content: stretch;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.rte-source-editor-btn {
|
|
376
|
+
flex: 1;
|
|
377
|
+
text-align: center;
|
|
378
|
+
}
|
|
379
|
+
}`, X = () => ({
|
|
380
|
+
name: "code",
|
|
381
|
+
// Toolbar button configuration
|
|
382
|
+
toolbar: [
|
|
383
|
+
{
|
|
384
|
+
label: "Source",
|
|
385
|
+
command: "toggleSourceView",
|
|
386
|
+
// type: "button",
|
|
387
|
+
icon: '<svg width="24" height="24" focusable="false"><g fill-rule="nonzero"><path d="M9.8 15.7c.3.3.3.8 0 1-.3.4-.9.4-1.2 0l-4.4-4.1a.8.8 0 0 1 0-1.2l4.4-4.2c.3-.3.9-.3 1.2 0 .3.3.3.8 0 1.1L6 12l3.8 3.7ZM14.2 15.7c-.3.3-.3.8 0 1 .4.4.9.4 1.2 0l4.4-4.1c.3-.3.3-.9 0-1.2l-4.4-4.2a.8.8 0 0 0-1.2 0c-.3.3-.3.8 0 1.1L18 12l-3.8 3.7Z"></path></g></svg>',
|
|
388
|
+
shortcut: "Mod-Shift-S"
|
|
389
|
+
}
|
|
390
|
+
],
|
|
391
|
+
// Native command implementations
|
|
392
|
+
commands: {
|
|
393
|
+
/**
|
|
394
|
+
* Toggle HTML source view
|
|
395
|
+
* Opens a dialog to edit raw HTML
|
|
396
|
+
*/
|
|
397
|
+
toggleSourceView: () => {
|
|
398
|
+
const l = (() => {
|
|
399
|
+
const a = window.getSelection();
|
|
400
|
+
if (a && a.anchorNode) {
|
|
401
|
+
let e = a.anchorNode instanceof HTMLElement ? a.anchorNode : a.anchorNode.parentElement;
|
|
402
|
+
for (; e; ) {
|
|
403
|
+
if (e.classList?.contains("rte-content"))
|
|
404
|
+
return e;
|
|
405
|
+
e = e.parentElement;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (document.activeElement) {
|
|
409
|
+
let e = document.activeElement;
|
|
410
|
+
if (e.classList?.contains("rte-content"))
|
|
411
|
+
return e;
|
|
412
|
+
for (; e && e !== document.body; ) {
|
|
413
|
+
if (e.classList?.contains("rte-content"))
|
|
414
|
+
return e;
|
|
415
|
+
const n = e.querySelector(
|
|
416
|
+
".rte-content"
|
|
417
|
+
);
|
|
418
|
+
if (n) return n;
|
|
419
|
+
e = e.parentElement;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
const o = document.querySelector("[data-editora-editor]");
|
|
423
|
+
if (o) {
|
|
424
|
+
const e = o.querySelector(
|
|
425
|
+
".rte-content"
|
|
426
|
+
);
|
|
427
|
+
if (e) return e;
|
|
428
|
+
}
|
|
429
|
+
return document.querySelector(".rte-content");
|
|
430
|
+
})();
|
|
431
|
+
if (!l)
|
|
432
|
+
return console.error("[CodePlugin] Editor content area not found"), alert(
|
|
433
|
+
"Editor content area not found. Please click inside the editor first."
|
|
434
|
+
), !1;
|
|
435
|
+
const A = l.innerHTML, N = (a) => {
|
|
436
|
+
let o = "", e = 0;
|
|
437
|
+
const n = 2, u = a.split(/(<\/?[a-zA-Z][^>]*>)/);
|
|
438
|
+
for (const r of u)
|
|
439
|
+
r.trim() && (r.match(/^<\/[a-zA-Z]/) ? (e = Math.max(0, e - 1), o += `
|
|
440
|
+
` + " ".repeat(e * n) + r) : r.match(/^<[a-zA-Z]/) && !r.match(/\/>$/) ? (o += `
|
|
441
|
+
` + " ".repeat(e * n) + r, e++) : r.match(/^<[a-zA-Z].*\/>$/) ? o += `
|
|
442
|
+
` + " ".repeat(e * n) + r : o += r.trim());
|
|
443
|
+
return o.trim();
|
|
444
|
+
};
|
|
445
|
+
return (() => {
|
|
446
|
+
const o = N(A);
|
|
447
|
+
let e = null, n = "dark", u = !1, r = !1, m = !1, w = !1;
|
|
448
|
+
const D = !!l.closest(L) || document.body.matches(L) || document.documentElement.matches(L), i = document.createElement("div");
|
|
449
|
+
i.className = "rte-source-editor-overlay", D && i.classList.add("rte-theme-dark");
|
|
450
|
+
const d = document.createElement("div");
|
|
451
|
+
d.className = "rte-source-editor-modal", d.setAttribute("role", "dialog"), d.setAttribute("aria-modal", "true"), d.setAttribute("aria-labelledby", "source-editor-title");
|
|
452
|
+
const h = document.createElement("div");
|
|
453
|
+
h.className = "rte-source-editor-header", h.innerHTML = `
|
|
454
|
+
<h2 id="source-editor-title">Source Editor</h2>
|
|
455
|
+
<div class="rte-source-editor-header-toolbar">
|
|
456
|
+
<button class="rte-source-editor-toolbar-btn theme-toggle-btn" title="Switch theme">
|
|
457
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
458
|
+
<circle cx="12" cy="12" r="5"/>
|
|
459
|
+
<line x1="12" y1="1" x2="12" y2="3"/>
|
|
460
|
+
<line x1="12" y1="21" x2="12" y2="23"/>
|
|
461
|
+
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/>
|
|
462
|
+
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
|
|
463
|
+
<line x1="1" y1="12" x2="3" y2="12"/>
|
|
464
|
+
<line x1="21" y1="12" x2="23" y2="12"/>
|
|
465
|
+
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
|
|
466
|
+
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
|
|
467
|
+
</svg>
|
|
468
|
+
</button>
|
|
469
|
+
<button class="rte-source-editor-toolbar-btn readonly-toggle-btn" title="Toggle read-only">
|
|
470
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
471
|
+
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
|
|
472
|
+
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
|
|
473
|
+
</svg>
|
|
474
|
+
</button>
|
|
475
|
+
</div>
|
|
476
|
+
<div class="rte-source-editor-header-actions">
|
|
477
|
+
<button class="rte-source-editor-fullscreen-btn" title="Toggle fullscreen">
|
|
478
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
479
|
+
<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
|
|
480
|
+
</svg>
|
|
481
|
+
</button>
|
|
482
|
+
<button class="rte-source-editor-close-btn" aria-label="Close source editor">
|
|
483
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
484
|
+
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
485
|
+
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
486
|
+
</svg>
|
|
487
|
+
</button>
|
|
488
|
+
</div>
|
|
489
|
+
`;
|
|
490
|
+
const E = document.createElement("div");
|
|
491
|
+
E.className = "rte-source-editor-body";
|
|
492
|
+
const v = document.createElement("div");
|
|
493
|
+
v.className = "rte-source-editor-content";
|
|
494
|
+
const C = document.createElement("div");
|
|
495
|
+
C.className = "rte-source-editor-warning", C.textContent = "⚠️ Advanced users only. Invalid HTML may break the editor.";
|
|
496
|
+
const b = document.createElement("div");
|
|
497
|
+
b.className = "rte-source-editor-light-editor", b.style.height = "400px", v.appendChild(C), v.appendChild(b), E.appendChild(v);
|
|
498
|
+
const f = document.createElement("div");
|
|
499
|
+
if (f.className = "rte-source-editor-footer", f.innerHTML = `
|
|
500
|
+
<div class="rte-source-editor-footer-info">
|
|
501
|
+
<span class="unsaved-changes" style="display: none;">• Unsaved changes</span>
|
|
502
|
+
</div>
|
|
503
|
+
<div class="rte-source-editor-footer-actions">
|
|
504
|
+
<button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
|
|
505
|
+
<button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
|
|
506
|
+
</div>
|
|
507
|
+
`, d.appendChild(h), d.appendChild(E), d.appendChild(f), i.appendChild(d), !document.getElementById("rte-source-editor-styles")) {
|
|
508
|
+
const t = document.createElement("style");
|
|
509
|
+
t.id = "rte-source-editor-styles", t.textContent = G, document.head.appendChild(t);
|
|
510
|
+
}
|
|
511
|
+
const x = h.querySelector(
|
|
512
|
+
".theme-toggle-btn"
|
|
513
|
+
), g = h.querySelector(
|
|
514
|
+
".readonly-toggle-btn"
|
|
515
|
+
), y = h.querySelector(
|
|
516
|
+
".rte-source-editor-fullscreen-btn"
|
|
517
|
+
), T = h.querySelector(
|
|
518
|
+
".rte-source-editor-close-btn"
|
|
519
|
+
), H = f.querySelector(
|
|
520
|
+
".rte-source-editor-btn-cancel"
|
|
521
|
+
), z = f.querySelector(
|
|
522
|
+
".rte-source-editor-btn-save"
|
|
523
|
+
), B = f.querySelector(
|
|
524
|
+
".unsaved-changes"
|
|
525
|
+
), M = [], s = (t, c, S, k) => {
|
|
526
|
+
t.addEventListener(c, S, k), M.push(
|
|
527
|
+
() => t.removeEventListener(c, S, k)
|
|
528
|
+
);
|
|
529
|
+
}, q = (t) => {
|
|
530
|
+
m !== t && (m = t, B && (B.style.display = m ? "inline" : "none"));
|
|
531
|
+
}, p = () => {
|
|
532
|
+
if (!w) {
|
|
533
|
+
for (w = !0; M.length; )
|
|
534
|
+
M.pop()?.();
|
|
535
|
+
e && (e.destroy(), e = null), i.isConnected && i.remove();
|
|
536
|
+
}
|
|
537
|
+
}, R = () => {
|
|
538
|
+
n = n === "dark" ? "light" : "dark", e?.setTheme(n), x && (x.innerHTML = n === "light" ? `
|
|
539
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
540
|
+
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
|
|
541
|
+
</svg>
|
|
542
|
+
` : `
|
|
543
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
544
|
+
<circle cx="12" cy="12" r="5"/>
|
|
545
|
+
<line x1="12" y1="1" x2="12" y2="3"/>
|
|
546
|
+
<line x1="12" y1="21" x2="12" y2="23"/>
|
|
547
|
+
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/>
|
|
548
|
+
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
|
|
549
|
+
<line x1="1" y1="12" x2="3" y2="12"/>
|
|
550
|
+
<line x1="21" y1="12" x2="23" y2="12"/>
|
|
551
|
+
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
|
|
552
|
+
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
|
|
553
|
+
</svg>
|
|
554
|
+
`);
|
|
555
|
+
}, O = () => {
|
|
556
|
+
u = !u, e?.setReadOnly(u), g && (g.classList.toggle("active", u), g.innerHTML = u ? `
|
|
557
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
558
|
+
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
|
|
559
|
+
<circle cx="12" cy="16" r="1"/>
|
|
560
|
+
<path d="M7 11V7a5 5 0 0 1 10 0v4"/>
|
|
561
|
+
</svg>
|
|
562
|
+
` : `
|
|
563
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
564
|
+
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
|
|
565
|
+
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
|
|
566
|
+
</svg>
|
|
567
|
+
`);
|
|
568
|
+
}, j = () => {
|
|
569
|
+
r = !r, i.classList.toggle("fullscreen", r), b.style.height = r ? "calc(100vh - 200px)" : "400px", y && (y.innerHTML = r ? `
|
|
570
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
571
|
+
<path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0 2-2h3M3 16h3a2 2 0 0 0 2 2v3"/>
|
|
572
|
+
</svg>
|
|
573
|
+
` : `
|
|
574
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
575
|
+
<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
|
|
576
|
+
</svg>
|
|
577
|
+
`);
|
|
578
|
+
}, F = () => {
|
|
579
|
+
m && !confirm("You have unsaved changes. Are you sure you want to cancel?") || p();
|
|
580
|
+
}, V = () => {
|
|
581
|
+
try {
|
|
582
|
+
const t = e?.getValue() || "", c = document.createElement("div");
|
|
583
|
+
c.innerHTML = t, c.querySelectorAll(
|
|
584
|
+
'script, iframe[src^="javascript:"], object, embed'
|
|
585
|
+
).forEach((k) => k.remove()), l.innerHTML = c.innerHTML;
|
|
586
|
+
try {
|
|
587
|
+
l.dispatchEvent(
|
|
588
|
+
new InputEvent("input", {
|
|
589
|
+
bubbles: !0,
|
|
590
|
+
cancelable: !1,
|
|
591
|
+
inputType: "insertReplacementText"
|
|
592
|
+
})
|
|
593
|
+
);
|
|
594
|
+
} catch {
|
|
595
|
+
l.dispatchEvent(
|
|
596
|
+
new Event("input", { bubbles: !0 })
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
l.dispatchEvent(
|
|
600
|
+
new Event("change", { bubbles: !0 })
|
|
601
|
+
), q(!1), p();
|
|
602
|
+
} catch (t) {
|
|
603
|
+
alert("Failed to update HTML. Please check your syntax."), console.error("HTML update error:", t);
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
x && s(x, "click", R), g && s(g, "click", O), y && s(y, "click", j), T && s(T, "click", p), H && s(H, "click", F), z && s(z, "click", V), s(i, "click", (t) => {
|
|
607
|
+
t.target === i && p();
|
|
608
|
+
}), s(document, "keydown", (t) => {
|
|
609
|
+
const c = t;
|
|
610
|
+
c.key === "Escape" && (c.preventDefault(), p());
|
|
611
|
+
}), document.body.appendChild(i), requestAnimationFrame(() => {
|
|
612
|
+
if (!(w || !i.isConnected))
|
|
613
|
+
try {
|
|
614
|
+
e = Z(b, {
|
|
615
|
+
value: o,
|
|
616
|
+
theme: "dark",
|
|
617
|
+
readOnly: !1,
|
|
618
|
+
extensions: [
|
|
619
|
+
new I(),
|
|
620
|
+
new U(),
|
|
621
|
+
new P(),
|
|
622
|
+
new _(),
|
|
623
|
+
new $(),
|
|
624
|
+
new K(),
|
|
625
|
+
new Y()
|
|
626
|
+
]
|
|
627
|
+
}), e.on("change", () => {
|
|
628
|
+
const t = e?.getValue() || "";
|
|
629
|
+
q(t !== o);
|
|
630
|
+
}), requestAnimationFrame(() => e?.focus());
|
|
631
|
+
} catch (t) {
|
|
632
|
+
console.error("Failed to initialize code editor:", t);
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
})(), !0;
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
// Keyboard shortcuts
|
|
639
|
+
keymap: {
|
|
640
|
+
"Mod-Shift-s": "toggleSourceView",
|
|
641
|
+
"Mod-Shift-S": "toggleSourceView"
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
export {
|
|
645
|
+
X as C
|
|
646
|
+
};
|